<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #img {
          width: 80%;
          padding: 10%;
        }
      </style>
</head>
<body>
    <img
      src="https://img.mukewang.com/5e6af63d00011da318720764.jpg"
      alt=""
      id="img"
    />
</body>
</html>
<script>
    //异步加载图片
    const loadImgAsync = url => {
        return new Promise((resolve,reject) => {
            const img = Image();
            img.onload = ()=>{
                resolve(img);
            };
            img.onerror = () => {
                reject(new Error(`Could not load image at ${url}`));
            }
            img.src = url;
        })
    }
    const imgDom = document.getElementById('img');
    loadImgAsync('https://2img.mukewang.com/5f057a6a0001f4f918720764.jpg')
    .then(img=>{
        console.log(img.src);
        setTimeout(()=>{
            imgDom.src = img.src;
        },1000);
    }).catch(error=>{
        console.log(err);
    }) 
</script>